Open
Conversation
Member
There was a problem hiding this comment.
here you use the "inspect" method on id ---- each object has both a to_s and an inspect method, but for different uses. Inspect should only be used for IRB style introspection. Basically looking at an object. Here you could just do:
"#{id}: #{name} airs at #{day_of_week}:#{hour_of_day}:00 on #{network} "
Member
|
Nice job! OK, so the deal with the asking you more than twice is a problem with recursion. In your example:
I reworked a tiny bit. See if this makes sense to you: def search_again
puts "Search Again (Y/N)"
answer = gets.upcase[0]
answer == "Y"
end
def find_show
keep_searching = true
while keep_searching do
puts "What day do you want to watch TV? (ex: Sunday)"
day = gets.chomp
shows = Show.find(:all, :conditions => {:day_of_week => day})
if shows.any?
shows.each do |show|
puts show
end
keep_searching = search_again
else
puts "There was nothing found for #{day}"
end
end
endThe important part above is setting the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I probably left in more output than I need to.
It also double-asks on search again after a valid search with a N answer for some reason. I can't figure out why.
I might touch on the Panda Level at some point, but right now, the ActiveRecord::Base API docs are just making me want to flip out.